package com.cube.dp.singleton;

/**
 * @author cube.li
 * @date 2021/12/12 18:53
 * <p>
 * 饿汉式单例模式
 */
public class EagerSingleton {

    @SuppressWarnings("InstantiationOfUtilityClass")
    private final static EagerSingleton EAGER_SINGLETON = new EagerSingleton();

    /**
     * 构造器私用,不允许外部主动创建,但是可以利用反射创建
     */
    private EagerSingleton() {
    }

    public static EagerSingleton getInstance() {
        return EAGER_SINGLETON;
    }
}
